package com.nulldev.util.scripting.cup.instruction_sets.sil.insts;

import java.util.Arrays;

import com.nulldev.util.VariableAPI.MathUtil;
import com.nulldev.util.scripting.cup.instructions.CupInstruction;

public class LoadNearestRegister implements CupInstruction {

	public static final String[] INST_ARGS =
		{ "A:AREG", "?B:NUM" };

	private final Object[] instructionArguments;

	public LoadNearestRegister(final Object... instArgs) {
		this.instructionArguments = instArgs;
	}

	@Override
	public String getDisplayableInstructionName() {
		return "LNR";
	}

	@Override
	public int getInstructionID() {
		return 1;
	}

	@Override
	public int getInstructionArgumentsCount() {
		return 2;
	}

	@Override
	public String[] getDefaultInstructionArguments() {
		return INST_ARGS;
	}

	@Override
	public int getOptionalInstructionArguments() {
		return 1;
	}

	@Override
	public int getRequiredInstructionArguments() {
		return 1;
	}

	@Override
	public Object[] getInstructionArguments() {
		return this.instructionArguments;
	}

	@Override
	public String toString() {
		return this.getDisplayableInstructionName() + "@" + MathUtil.toHex(super.hashCode()) + Arrays.toString(this.instructionArguments);
	}
}
